package org.luxor.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.luxor.commons.core.utils.BeanUtils;
import org.luxor.system.entity.SysRoleMenuRefEntity;
import org.luxor.system.mapper.SysRoleMenuRefMapper;
import org.luxor.system.service.ISysRoleMenuRefService;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Map;

/**
 * 角色与菜单对应关系
 *
 * @author Mark @date 2020-07-26 16:52:22
 */
@Service("sysRoleMenuRefService")
public class SysRoleMenuRefServiceImpl extends ServiceImpl<SysRoleMenuRefMapper, SysRoleMenuRefEntity> implements ISysRoleMenuRefService {

    @Override
    public IPage<SysRoleMenuRefEntity> page(IPage<SysRoleMenuRefEntity> page, Map query) {
        SysRoleMenuRefEntity queryEntity = BeanUtils.toObject(SysRoleMenuRefEntity.class, query);
        return super.page(page, Wrappers.query(queryEntity));
    }

    @Override
    public Collection<SysRoleMenuRefEntity> listByRoleId(Long roleId) {
        Wrapper<SysRoleMenuRefEntity> queryWrapper = Wrappers.<SysRoleMenuRefEntity>lambdaQuery()
                .eq(SysRoleMenuRefEntity::getRoleId, roleId);
        return getBaseMapper().selectList(queryWrapper);
    }

}
